﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Reflection;
using System.Drawing;
using DevExpress.XtraEditors;

namespace ErickOrlando.Utilidades.Windows.Controles
{

    public class PlantillaBotonActionList : DesignerActionList
    {

        #region  Campos Privados

        private PlantillaBoton m_PlantillaBoton;
        private DesignerActionUIService designerActionUISvc = null;

        #endregion

        #region  Constructor

        public PlantillaBotonActionList(IComponent component)
            : base(component)
        {
            this.m_PlantillaBoton = (PlantillaBoton)component;

            this.designerActionUISvc = (DesignerActionUIService)GetService(typeof(DesignerActionUIService));

        }

        #endregion

        #region  Propiedades y Funciones

        private PropertyDescriptor GetPropertyByName(string propName)
        {
            PropertyDescriptor prop;
            prop = TypeDescriptor.GetProperties(m_PlantillaBoton)[propName];
            if (prop == null)
                throw new ArgumentException("Propiedad no encontrada!", propName);
            else
                return prop;
        }

        public TextEdit CajaTexto
        {
            get { return m_PlantillaBoton.CajaTexto; }
            set { GetPropertyByName("CajaTexto").SetValue(m_PlantillaBoton, value); }
        }

        public ButtonEdit CajaTextoConBoton
        {
            get { return m_PlantillaBoton.CajaTextoConBoton; }
            set { GetPropertyByName("CajaTextoConBoton").SetValue(m_PlantillaBoton, value); }
        }

        public PlantillaBoton.TipoBoton Imagen
        {
            get { return m_PlantillaBoton.Imagen; }
            set { GetPropertyByName("Imagen").SetValue(m_PlantillaBoton, value); }
        }

        public override System.ComponentModel.Design.DesignerActionItemCollection GetSortedActionItems()
        {
            DesignerActionItemCollection items = new DesignerActionItemCollection();

            items.Add(new DesignerActionHeaderItem("Apariencia"));
            items.Add(new DesignerActionHeaderItem("Comportamiento"));

            items.Add(new DesignerActionPropertyItem("CajaTexto", "Caja de Texto", "Comportamiento", "Permite establecer una Caja de Texto al botón"));

            items.Add(new DesignerActionPropertyItem("CajaTextoConBoton", "Caja de Texto con Botón", "Comportamiento", "Permite establecer un ButtonEdit al botón"));

            items.Add(new DesignerActionPropertyItem("Imagen", "Imagen del botón", "Apariencia", "Permite colocar una imagen estándar al botón"));

            return items;

        }

        #endregion

    }
}